Resource profiling reference

Here you can find the reference for resource profiling data. Use resource profiling to measure during runtime how long it takes to load and deploy resources and prefabs in your Kanzi application. To learn more about resource profiling, see Measuring the loading and deployment time of resources.

Kanzi resource profiling data contains:

Resource profiling contexts

A resource profiling context represents a scope that executes code path which triggers resource loading or deployment. A resource profiling context sampler creates a resource profiling context when the execution of the scope where the sampler is defined, triggers resource loading or deployment. The duration of a resource profiling context is the same as the duration of the resource loading or deployment triggered by the execution of the corresponding scope.

In scopes where resources are loaded and deployed Kanzi creates samplers for the profiling contexts of resource loading and deployment ResourceProfilingLoadContext and ResourceProfilingDeployContext.

This table lists the common attributes of resource profiling contexts. All contexts have these attributes.

Common attribute Description
ContextID Unique identifier of the resource profiling context.
Use the identifier to find out in which thread the context was created, the parent context, and the thread which triggered the execution of the context.
ContextName Name of the resource profiling context.
DependenciesDuration Time in nanoseconds it took for the Kanzi main thread to load and deploy the resources that the resource depends on.
Duration Time in nanoseconds it took for the Kanzi main thread to load and deploy the resource and those resources that the resource depends on.
TimeStamp Time point of entering the scope of the resource profiling context.
Use the timestamp to find out when different resource profiling contexts were created relative to each other.
DependencyContexts List of dependency contexts.
   

This table lists the profiling context types and the attributes that they have in addition to the common attributes.

Resource profiling context Context name Description Additional attributes
Main loop MainLoop The profiler creates this context when the application loads or deploys a resource during the Kanzi main loop iteration. MainLoopCounter - The iteration during which the context is created.
Resource acquirement ResourceAcquire The profiler creates this context when resource acquisition triggers the loading or deployment of the resource.
  • AcquireAsynchronously - "true" if resource loading is asynchronous, "false" if resource loading is synchronous.
  • ResourceUrl - The kzb URL of the resource which the application is acquiring.
Resource loading ResourceLoading The profiler creates this context when the application loads the resource.
  • LoadedResourceID - The unique identifier of the loaded resource. Use this attribute to distinguish between different occasions of loading a resource again after it was purged.
  • LoadedResourceType - The type of the loaded resource.
    For example, Kanzi.Material, Kanzi.PrefabTemplate, Kanzi.ResourceDictionary, or Kanzi.ShaderProgram.
  • LoadedResourceUrl - The URL of the loaded resource.
  • ResourceLoadingDuration - The time in nanoseconds it took a loading thread to load the resource.
Resource deployment ResourceDeployment The profiler creates this context when the application deploys the resource.
  • DeployedResourceID - The unique identifier of the deployed resource.
  • DeployedResourceType - The type of the deployed resource.
  • DeployedResourceUrl - The URL of the deployed resource.
  • ResourceLoadingDuration - The time in nanoseconds it took the Kanzi main thread to deploy the resource.
Acquirement of anonymous resource AcquireAnonymousResource The profiler creates this context when the application acquires a resource that does not have a resource ID. This usually happens when acquiring a resource dictionary. -
Asynchronous acquirement of resources AcquireResourcesAsynchronously The profiler creates this context when the application acquires multiple resources asynchronously.
See Loading prefab resources asynchronously.
-
FinishingQueue: process task FinishingQueue::processTask The profiler creates this context when Kanzi processes a task which loads or deploys a resource. This context is usually the parent of one or more Resource loading or Resource deployment contexts. Description - Information about the index of the resource loading task and task queue size.
For example, "Task index 1, queue size 2".
Prefab template instantiation PrefabTemplateInstantiate The profiler creates this context when the instantiation of a prefab template triggers resource loading or deployment. Description - The root node of the prefab instance.
For example, "Node root: Screen".
Prefab template node instantiation PrefabTemplateNodeInstantiate The profiler creates this context when the instantiation of a node in a prefab template triggers resource loading or deployment. Description - The name of the node in the prefab instance.
For example, "Node name: Viewport 2D".
Node attachment Node::attach The profiler creates this context when the attaching of a node to the scene graph triggers resource loading or deployment. Description - The name of the node that is attached.
For example, "Node name: Plane".
Message trigger MessageTrigger The profiling system creates this context when the handling of a message trigger results in resource loading or deployment. Description - The source of the trigger message.
For example, "Message source: Button 2D".
Application process deployment queue Application::progressDeploymentQueue The profiler creates this context when the execution of the Application::progressDeploymentQueue() function triggers resource loading or deployment. This context is always a child of the Main loop context. -
Application process deployment queue override (default) Application::progressDeploymentQueueOverride(default) The profiler creates this context when the execution of the Kanzi implementation of the Application::progressDeploymentQueueOverride() function triggers resource loading or deployment. -
Waiting loading queue task completion WaitingLoadingQueueTaskCompletion The profiler creates this context when the resource that the application is acquiring is being loaded by one of the loading threads and the main thread has to wait for that loading thread to finish loading. -
       

Resource profiling data samples

A resource profiling data sample includes a summary of profiling information related to a profiled resource, including references to the resource profiling contexts in which the resource is acquired, loaded, and deployed.

You can find a list of all the resource profiling data samples in the "ResourceProfilingDataSamples" section of a resource profiling data file. See Logging resource profiling data.

Use the ContextID attribute of a resource profiling context to find out in which thread the resource profiler creates a resource profiling context, what is the parent context, and the thread which triggered the execution of the context. See Resource profiling contexts.

This table lists the attributes of a resource profiling data sample.

Attribute Description
DeploymentDuration Time in nanoseconds it took to deploy the resource
LoadingDuration Time in nanoseconds it took to load the resource
ResourceID Unique identifier of the resource profiling data sample
ResourceType Type of the profiled resource
ResourceUrl URL of the profiled resource
AcquireContext Resource profiling context in which the application or Kanzi acquired the resource
LoadingContext Resource profiling context in which Kanzi loaded the resource
DeploymentContext Resource profiling context in which Kanzi deployed the resource
   

This is the resource profiling data sample of the City mesh in the Scroll view example.

            "DeploymentDuration": "52920957",
            "LoadingDuration": "869380",
            "ResourceID": "233255432",
            "ResourceType": "Kanzi.Mesh",
            "ResourceUrl": "kzb://scroll_view/Mesh Data/City",
            "AcquireContext": {
                "AcquireAsynchronously": "true",
                "ContextID": "199287920",
                "ContextName": "ResourceAcquire",
                "DependenciesDuration": "0",
                "ResourceUrl": "kzb://scroll_view/Mesh Data/City",
                "TimeStamp": "107551499"
            },
            "LoadingContext": {
                "ContextID": "234230448",
                "ContextName": "ResourceLoading",
                "DependenciesDuration": "0",
                "LoadedResourceID": "233255432",
                "LoadedResourceType": "Kanzi.Mesh",
                "LoadedResourceUrl": "kzb://scroll_view/Mesh Data/City",
                "ResourceLoadingDuration": "869380",
                "TimeStamp": "626864207"
            },
            "DeploymentContext": {
                "ContextID": "234146616",
                "ContextName": "ResourceDeployment",
                "DependenciesDuration": "47990578",
                "DeployedResourceID": "233255432",
                "DeployedResourceType": "Kanzi.Mesh",
                "DeployedResourceUrl": "kzb://scroll_view/Mesh Data/City",
                "DeploymentDuration": "4930379",
                "TimeStamp": "647530216",
                "DependencyContexts": [
                    { ... }
            }

See also

Measuring the loading and deployment time of resources

Resources

Using prefabs

Scroll view example